from abc import ABC, abstractmethod


__all__ = ["Unmarshaler"]


class Unmarshaler[T](ABC):
    """
    An unmarshaler.

    An unmarshaler is an object that can unmarshal data into a stage. This is useful for parsing data and form
    stages, for example, extracting users from excel sheets.
    """

    @abstractmethod
    def unmarshal(self) -> T:
        """
        Unmarshal data into a stage.

        This method does not take any arguments. Any possible arguments should be passed in the constructor of the
        unmarshaler (e.g. a file path).

        Returns:
            The unmarshaled stage.
        """
        raise NotImplementedError()

    def __call__(self, _: None = None) -> T:
        return self.unmarshal()
